<?php

/**
 * File Description
 * 
 * Kao: PHP Web Framework <http://www.byhuy.com/kao/>.
 * Copyright 2007-2008, Huy Nguyen <http://www.byhuy.com/>.
 * 
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */


abstract class Kao_Resource_Abstract
{
    
    /**
     * Sub-resources definitions
     * 
     * @var array
     */
    protected $_subResources = array();
    
    
    /**
     * Request object
     * This object handles request informations
     * 
     */
    protected $_request = null;
    
    /**
     * Response object
     * Handles http response
     */
    protected $_response = null;
   
    /**
     * The method name for current request
     */
    protected $_handlerFunction = 'notfound';
    
    /**
     * The HTTP Method
     * 
     * GET | POST | PUT | DELETE | HEAD
     */
    protected $_httpMethod = '';
    
    /**
     * Dispatch method
     * 
     * Handles and call the
     */
    public function dispatch(Kao_Http_Request $request)
    {
        $this->_request = $request;
        $this->_response = new Kao_Http_Response();
        
        $this->_httpMethod = $this->_request->getMethod();
        
        $this->_setHandlerFunction($this->_httpMethod);
        
        $this->{$this->_handlerFunction}();
        
        return $this->_response;
    }
    
    protected function _setHandlerFunction($httpMethod)
    {
        $this->_handlerFunction = strtolower($httpMethod);
    }
    
    public function getNextResourceName($name)
    {
        
    }
    
    public function get()
    {
        
    }
    
    public function post()
    {
        
    }
    
    public function put()
    {
        
    }
    
    public function head()
    {
        
    }
    
    public function delete()
    {
        
    }
}

